package com.aaa.demo10;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author ${崔灿}
 * @date 2022/11/02 19:27
 **/

public class Test {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);

        for (int i = 0; i < 5; i++ ) {
            executorService.submit(new Runnable() {

                @Override
                public void run() {
                    for (int j = 0; j < 20;j++) {
                        System.out.println(Thread.currentThread().getName());
                    }
                }
            });

            //关闭线程池， ---任务没有执行完，就被打断
            executorService.shutdownNow();

            boolean shutdown = executorService.isShutdown();
            System.out.println(shutdown);

            //判断线程池是否终止---里面的任务执行完毕
            boolean b = executorService.isTerminated();
            System.out.println(b);
        }
    }
}
